This patch prevents you from getting a screen full of stack trace when
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:16:39 +0000 (15:16 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 26 Jul 2005 15:16:39 +0000 (15:16 +0000)
trying to run commands like xm list as a normal user, and instead provides a
helpful error message.

Signed-off-by: Sean Dague <sean@dague.net>
tools/python/xen/xm/main.py

index 7ccea722a0fb5f0baf2048cf83839133af53f182..8f8c757e315dff8d2c0e8f53467817e5fc3fa09f 100644 (file)
@@ -11,6 +11,13 @@ warnings.filterwarnings('ignore', category=FutureWarning)
 
 from xen.xend import PrettyPrint
 from xen.xend import sxp
+# this is a nasty place to stick this in, but required because
+# log file access is set up via a 5 deep import chain.  This
+# ensures the user sees a useful message instead of a stack trace
+if os.getuid() != 0:
+    print "xm requires root access to execute, please try again as root"
+    sys.exit(1)
+
 from xen.xend.XendClient import XendError, server
 from xen.xend.XendClient import main as xend_client_main
 from xen.xm import create, destroy, migrate, shutdown, sysrq